{ "cells": [ { "cell_type": "markdown", "id": "94299699-3b41-4149-a870-db571ffd944c", "metadata": {}, "source": [ "# Copy Number Variation" ] }, { "cell_type": "code", "execution_count": null, "id": "88be5cea-2412-41f3-bd2c-8447fb7616a7", "metadata": {}, "outputs": [], "source": [ "from pylluminator.samples import Samples\n", "from pylluminator.cnv import copy_number_variation, copy_number_segmentation\n", "from pylluminator.utils import set_logger\n", "from pylluminator.visualizations import cns_manhattan_plot\n", "\n", "set_logger('WARNING') # set the verbosity level, can be DEBUG, INFO, WARNING, ERROR" ] }, { "cell_type": "markdown", "id": "1370e2cc-bb01-40c4-828f-98df3dabc7f2", "metadata": {}, "source": [ "## Load pylluminator Samples\n", "\n", "We assume that you have already processed the .idat files according to your preferences and saved them. If not, please refer to notebook `1 - Read data and get beta values` before going any further." ] }, { "cell_type": "code", "execution_count": null, "id": "0988935f-7779-46e0-b546-145c0652bcdc", "metadata": {}, "outputs": [], "source": [ "my_samples = Samples.load('preprocessed_samples')\n", "my_samples" ] }, { "cell_type": "code", "execution_count": null, "id": "b63ff882-d0a4-421a-83c4-8f4131f784f3", "metadata": {}, "outputs": [], "source": [ "sample_sheet = my_samples.sample_sheet\n", "sample_sheet" ] }, { "cell_type": "markdown", "id": "5868c013-7901-46e1-8504-e9dc9c33590f", "metadata": {}, "source": [ "## Get CNVs for a sample group\n", "\n", "Using the PrEC samples as normalizations samples, we can calculate the Copy Number Variation per probe for LNCaP samples, and group the bins in segments depending on their copy number." ] }, { "cell_type": "code", "execution_count": null, "id": "33992775-4ff4-41b3-8adc-749d93e01bc0", "metadata": {}, "outputs": [], "source": [ "cnv_df = copy_number_variation(my_samples, group_by='sample_type', normalization_labels='PREC')\n", "\n", "ranges, signal_bins_df, segments_df = copy_number_segmentation(my_samples, cnv_df, 'LNCAP')" ] }, { "cell_type": "markdown", "id": "85f5adb1-d7c8-4f87-a21f-71a27dec1b31", "metadata": {}, "source": [ "## Visualize CNVs and segments" ] }, { "cell_type": "markdown", "id": "819b8510-78ba-49f3-8d14-b91606f40b9a", "metadata": {}, "source": [ "Plot the identified segments and CNV values" ] }, { "cell_type": "code", "execution_count": null, "id": "336ccc68-5994-455b-aeb0-d7eb5273c2c1", "metadata": {}, "outputs": [], "source": [ "cns_manhattan_plot(signal_bins_df, segments_df)" ] } ], "metadata": { "kernelspec": { "display_name": "pylluminator", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }